package com.leen.admin.repository;


import com.leen.admin.entity.Role;
import org.hibernate.annotations.SQLUpdate;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * 类说明
 *
 * @author Role
 * @date 2021-05-11
 */
@Repository
public interface RoleRepository  extends CrudRepository<Role,Integer>,JpaSpecificationExecutor<Role> {

    @Modifying
    @Query(value = "delete from sys_role_menu where role_id=:roleId",nativeQuery = true)
    int deleteByRoleId(@Param(value = "roleId") int roleId);

    @Modifying
    @Query(value = "insert into  sys_role_menu(role_id,menu_id) values(:roleId,:menuId)",nativeQuery = true)
    int insertBatch(@Param(value = "roleId") int roleId, @Param(value = "menuId") int menuId);
}
